package md5;


import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author fangjiaxiaobai@gmail.com[公众号：方家小白]
 * @date 2020-05-30 15-59
 * @since 1.0.0
 */
public class MD5Demo {
    public static void main(String[] args) throws NoSuchAlgorithmException {
        System.out.println(md5("123456789"));
        System.out.println(md5("123456788"));
    }
    private static String md5(String input) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(input.getBytes());
        byte[] digest = md5.digest();
        return new BigInteger(1, digest).toString(16);
    }
}
